//使用trait bounds 有条件的实现方法
trait GetName{
    fn get_name(&self)->String;
}
trait GetAge{
    fn get_age(&self)->u32;
}

struct PeopleMatchInformation<T,U>{
    master:T,
    student:U
}
impl <T,U>PeopleMatchInformation<T,U>
where T:GetAge+GetName,
      U:GetAge+GetName
{
    fn print_all_information(&self){
        println!("master name:{}\n master age:{}",self.master.get_name(),self.master.get_age());
        println!("student name:{}\n student age:{}",self.student.get_name(),self.student.get_age());

    }

}
struct Teacher{
    name:String,
    age:u32
}
impl GetName for Teacher{
    fn get_name(&self)->String{
       format!("{}", self.name)
    }
}impl GetAge for Teacher{
    fn get_age(&self)->u32{
        self.age
    }
}
struct Student{
    name:String,
    age:u32
}
impl GetName for Student{
    fn get_name(&self)->String{
       format!("{}", self.name)
    }
}impl GetAge for Student{
    fn get_age(&self)->u32{
        self.age
    }
}

fn main(){
    let t=Teacher{
        name:String::from("ch"),
        age:12
    };
    let s=Student{
        name:String::from("xxx"),
        age:44
    };
    let p=PeopleMatchInformation{master:t,student:s};
     p.print_all_information();
}